package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.MarketBrand;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.wx.WxBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.xml.bind.ValidationException;


/**
 * 品牌的service层
 * url:/wx/brand
 *
 * @Author: zhang
 * @Date: 2022/11/22 19:28
 * @Since: jdk1.8
 */
@RestController
@RequestMapping("wx/brand")
public class WxBrandController {
    @Autowired
    WxBrandService wxBrandService;

    /**
     * 查询所有的品牌信息
     *
     * @param page  页码
     * @param limit 一页显示几个
     * @return BaseRespVo<MarketBrand>
     */
    @GetMapping("list")
    public BaseRespVo<MarketBrand> list(Integer page, Integer limit) throws ValidationException {
        CommonData<MarketBrand> data = wxBrandService.list(page, limit);
        return BaseRespVo.ok(data);
    }

    /**
     * 查询品牌的详细信息
     *
     * @param id 品牌id
     * @return 品牌信息
     */
    @RequestMapping("detail")
    public BaseRespVo<MarketBrand> detail(Integer id) throws ValidationException {
        MarketBrand data = wxBrandService.detail(id);
        return BaseRespVo.ok(data);
    }
}
